package com.djf.djfauth.config;

import me.zhyd.oauth.config.AuthConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author 26393
 * @Date 2025/7/7 2:20
 * @Version 1.0
 */
@Configuration
public class JustAuthConfig {
    @Value("${justauth.qq.client-id}")
    private String qqClientId;
    @Value("${justauth.qq.client-secret}")
    private String qqClientSecret;
    @Value("${justauth.qq.redirect-uri}")
    private String qqRedirectUri;

    @Value("${justauth.weixin.client-id}")
    private String weixinClientId;
    @Value("${justauth.weixin.client-secret}")
    private String weixinClientSecret;
    @Value("${justauth.weixin.redirect-uri}")
    private String weixinRedirectUri;

    @Value("${justauth.dingtalk.client-id}")
    private String dingtalkClientId;
    @Value("${justauth.dingtalk.client-secret}")
    private String dingtalkClientSecret;
    @Value("${justauth.dingtalk.redirect-uri}")
    private String dingtalkRedirectUri;

    @Bean("qqAuthConfig")
    public AuthConfig qqConfig() {
        return AuthConfig.builder()
                .clientId(qqClientId)
                .clientSecret(qqClientSecret)
                .redirectUri(qqRedirectUri)
                .build();
    }

    @Bean("weixinAuthConfig")
    public AuthConfig weixinConfig() {
        return AuthConfig.builder()
                .clientId(weixinClientId)
                .clientSecret(weixinClientSecret)
                .redirectUri(weixinRedirectUri)
                .build();
    }

    @Bean("dingtalkAuthConfig")
    public AuthConfig dingtalkConfig() {
        return AuthConfig.builder()
                .clientId(dingtalkClientId)
                .clientSecret(dingtalkClientSecret)
                .redirectUri(dingtalkRedirectUri)
                .build();
    }

    //gitee
    @Value("${justauth.gitee.client-id}")
    private String giteeClientId;
    @Value("${justauth.gitee.client-secret}")
    private String giteeClientSecret;
    @Value("${justauth.gitee.redirect-uri}")
    private String giteeRedirectUri;

    @Bean("giteeAuthConfig")
    public AuthConfig giteeConfig() {
        return AuthConfig.builder()
                .clientId(giteeClientId)
                .clientSecret(giteeClientSecret)
                .redirectUri(giteeRedirectUri)
                .build();

    }
}
